<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>{{$wenzhanglist->title}}</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="format-detection" content="telephone=no">
    <meta name="description" content="{{mb_substr(strip_tags($wenzhanglist->content),0,100)}}...">
    <meta name="keywords" content="夜读书,帖子">
    <link rel="stylesheet" href="{{ asset('/style/css/faxian.css') }}">
    <script src="{{ asset('/scripts/jquery/jquery-1.11.3.min.js') }}"></script>
    <link rel="stylesheet" href="{{ asset('/scripts/PhotoSwipe/css/photoswipe.css') }}"> 
    <link rel="stylesheet" href="{{ asset('/scripts/PhotoSwipe/css/default-skin/default-skin.css') }}"> 
    <script src="{{ asset('/scripts/PhotoSwipe/js/photoswipe.min.js') }}"></script> 
    <script src="{{ asset('/scripts/PhotoSwipe/js/photoswipe-ui-default.min.js') }}"></script>
</head>
<body class="ns-cricle-bg ">
    <div class="mod-card" style="height:39px;font-size:14px;position: fixed;top: 0;left: 0;width: 100%;z-index: 999;">
            <div class="" style="padding: 10px 20px;">
                <!-- <a href="javascript:;" onClick="javascript:history.back(-1);"> -->
                <a href="{{url('wenzhang/lists')}}">
                    <span class=""><<返回</span>
                </a>
            </div>
        </div>
    <div id="container">
        <div class="mod-post" style="padding-top: 30px;">
            <div class="mod-post-list-item">
                <div class="article-title">{{$wenzhanglist->title}}</div>
                <div class="mod-feed-header ">
                    <div class="mod-avatar">
                        <div class="G-img-wrap">
                            @if(Session::get('nameid') == $users->uid)
                                <a class="aw-user-name" href="{{url('mobile/myhome')}}">
                            @else
                                <a class="aw-user-name" href="{{url('mobile/uhome/'. $users->uid)}}">
                            @endif
                            @if($users->avatar_file_min!="")
                                <img src="{{ url($users->avatar_file_min) }}">
                            @else
                                <img src="{{url('usersface/default/avatar-min.png')}}">
                            @endif
                            </a>
                        </div>
                    </div>                    
                    <div class="usr-name">
                        <span class="name flex-wrap">
                            <p class="username">{{$users->user_name}}</p>
                            <p class="ty">
                                <span class="time" style="">{{date('m-d',$wenzhanglist->add_time)}}</span> 
                                <span class="yue" style="padding-left:10px;">阅: {{$wenzhanglist->click}}</span>
                            </p>
                        </span>
                    </div>                   
                </div>
                <div class="mod-feed-content">{!!$wenzhanglist->content!!}</div>
                <!-- @if($imglist_arr != 0)
                <div class="mod-feed-img">
                    @foreach($imglist_arr as $key => $img)
                    <div class="g-img-item" style="margin-bottom: 1.25%;cursor:pointer;" onclick="openPhotoSwipe('{{$imglist}}', {{$key}})">
                        <img src="{{url('wenzhang_img/' . $img)}}">
                    </div>
                    @endforeach
                </div>
                @endif -->
                <div class="x-mod-comment-box">
                    <div class=""><span class="title">全部评论</span></div>
                    @if(count($wenzhang_pingluns) != 0)
                        @foreach($wenzhang_pingluns as $pinglun)
                        <ul class="comment-list">
                            <li class="comment-list-item">
                                <div class="mod-avatar">
                                    <div class="G-img-wrap">
                                        @if(Session::get('nameid') == $users->uid)
                                            <a href="{{url('mobile/myhome')}}">
                                        @else
                                            <a href="{{url('mobile/uhome/'. $users->uid)}}">
                                        @endif
                                        @if($pinglun->users->avatar_file_min!="")
                                            <img src="{{url($pinglun->users->avatar_file_min)}}">
                                        @else
                                            <img src="{{url('usersface/default/avatar-min.png')}}">
                                        @endif
                                            </a>
                                    </div>
                                </div>
                                <div class="content">
                                    <div class="content-info">
                                        <div class="content-info-text">
                                            <div class="name-box"><span class="name">{{$pinglun->users->user_name}}</span></div>
                                            <div class="name-desc"><span class="desc">{{date('m-d',$pinglun->add_time)}}</span></div>
                                        </div>
                                    </div>
                                    <div class="content-main">{!!$pinglun->content!!}</div>
                                </div>
                            </li>
                        </ul>
                        @endforeach                        
                        <div class="mod-loading no-comment">没有更多内容...</div>
                    @else
                        <div class="no-comment">暂无评论</div>
                    @endif
                </div>
                <div class="mod-article-footbar">
                    <div class="input" onclick="urlpinglun();">我来说两句</div>
                    <div class="opt">
                        <a href="javascript:;" onClick="dianzan({{$wenzhanglist->id}});">
                            <span class="up-num">点赞</span>
                            <span class="dianzan">{{$dianzan_count}}</span>
                        </a>
                    </div>
                </div>
            </div>            
        </div>
    </div>

    @include('wenzhang.showpic')
    
<script>
function openPhotoSwipe(data,index)
{    
    //alert(index);
    var arr = data.split(',');
    var pswpElement = document.querySelectorAll('.pswp')[0];
    // var items = [
    //     {
    //         src: data,
    //         w: 950,
    //         h: 534
    //     }
    // ];
    var items = [];
    for ( var i = 0; i < arr.length; i++) {
        items.push({src:'{{url('wenzhang_img'). '/'}}' + arr[i],w:964,h:1024});
        //console.log(arr[i]);
    }
    
    var options = {
        index: index,
        loop: false,
        closeOnScroll: false,       
        history: true,
        focus: true,
        showAnimationDuration: 0,
        hideAnimationDuration: 0
        
    };
    
    var gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
    gallery.init();
}

function urlpinglun()
{
    window.location.href = '{{url('wenzhang/pubwenzhang_pinglun')}}/' + '{{$id}}';
}

function dianzan(wenzhangid)
{
    //点赞
    $.ajax({
        type : 'POST',
        url : '{{url('wenzhang/dianzan')}}',
        data : {
            'wenzhangid' : wenzhangid
        },
        dataType : 'html',
        success : function(data) {
            if(data == 1)
            {
                Toast('登录后点赞', 1000);
            }
            if(data == 2)
            {
                Toast('+1', 1000);
                var n = $('.dianzan').html();
                n++;
                $('.dianzan').html(n);
            }
            if(data == 3)
            {
                Toast('你已经点过赞了', 1000);
            }
        },
        error : function(e) {
            //console.log(e);
            alert('发表失败');
        }
    });
}

//自定义弹框
function Toast(msg,duration){
    duration=isNaN(duration)?3000:duration;
    var m = document.createElement('div');
    m.innerHTML = msg;
    m.style.cssText="padding:0 6px;opacity: 0.7;height: 30px;color: rgb(255, 255, 255);line-height: 30px;text-align: center;border-radius: 5px;position: fixed;top: 40%;left: 50%;transform:translate(-50%,-50%);-webkit-transform: translateX(-50%);-ms-transform: translateX(-50%);z-index: 999999;background: rgb(0, 0, 0);font-size: 12px;";
    document.body.appendChild(m);
    setTimeout(function() {
        var d = 0.5;
        m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
        m.style.opacity = '0';
        setTimeout(function() { document.body.removeChild(m) }, d * 1000);
    }, duration);
}
</script> 
</body>
</html>